import { v4 as uuidv4 } from 'uuid';

function generateRandomCode(length: number) {
    const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
    let result = '';
    for (let i = 0; i < length; i++) {
        const randomIndex = Math.floor(Math.random() * characters.length);
        result += characters.charAt(randomIndex);
    }
    return result;
}


export namespace MarkUtils {

    //生成团号
    export function createTourGroupNumber(prefix?: string) {
        return (prefix || "") + generateRandomCode(5) ;
    }

    //生成公司邀请码
    export function createCompanyCode() {
        const uuid = uuidv4();
        return  Buffer.from(uuid).toString("base64")
    }

    //生成tokenID
    export function createTokenId() {
        const uuid = uuidv4();
        return uuid;
    }
}